package com.xyzwps.lib.openapi.element;

import com.xyzwps.lib.bedrock.Args;

import java.util.HashMap;
import java.util.Map;

public class Discriminator implements OASElement {

    private final String propertyName;
    private final Map<String, String> mapping = new HashMap<>();

    public Discriminator(String propertyName) {
        this.propertyName = Args.notEmpty(propertyName, "propertyName cannot be empty.");
    }

    public Discriminator addMapping(String key, String value) {
        mapping.put(Args.notEmpty(key, "key cannot be empty."), Args.notEmpty(value, "value cannot be empty."));
        return this;
    }

    public Map<String, String> mapping() {
        return mapping;
    }

    public String propertyName() {
        return propertyName;
    }

    @Override
    public void accept(OAEVisitor visitor) {
        visitor.visit(this);
    }
}
